package cn.swing.his.passport.controller;

import cn.swing.his.common.web.JsonResult;
import cn.swing.his.passport.service.IDoctorService;
import cn.swing.his.pojo.password.dto.DoctorLoginDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/doctor", produces = "application/json;charset=utf-8")
@Api(tags = "登录模块")
public class DoctorSSOController {
    @Autowired
    private IDoctorService doctorService;

    @ApiOperation("问好")
    @GetMapping("/hello")
    @PreAuthorize("hasAuthority('用户管理')")
    public String sayHello(){
        return "hello!!!!!!!!!!!!!!!!!!!!!!!";
    }

    @ApiOperation("登录")
    @PostMapping("/login")
    public JsonResult<String> doctorLogin(DoctorLoginDTO doctorLoginDTO){
        String jwt = doctorService.doLogin(doctorLoginDTO);
        return JsonResult.ok("登录成功!",jwt);
    }
}
